package com.shun.controller

import com.shun.commons.exception.ApiException
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody

/**
 * Created by rainbow on 2017/6/15.
 *一事专注，便是动人；一生坚守，便是深邃！
 */

class HandlerController {

    private val logger by lazy { LoggerFactory.getLogger(HandlerController::class.java) }

    @ExceptionHandler
    @ResponseBody
    fun exceptionHandler(ex: RuntimeException): Any {

        logger.error(ex.message)

        return mapOf("success" to false, "message" to ex.message)
    }
}